/*
 * CS_READ_MAIL_DELETE.cpp
 *
 *  Created on: 2013. 5. 21.
 *      Author: the2
 */

#include "../../Command.h"
#include "../../User.h"
#include "../../NLogic/MailBox.h"

namespace ProjectZ { namespace NCommand {

void Command::CS_READ_MAIL_DELETE(User * pUser, ::Network::Packet * pPacket)
{
	PREPARE_PACKET;

	uint64_t mailSeq;

	*pPacket >> mailSeq;

	NLogic::MailBox * pMailBox = pUser->GetMailBox();
	if (NULL == pMailBox)
	{
		DEBUGLOG("CS_READ_MAIL_DELETE : pMailBox is NULL!!");
		return;
	}

	NLogic::MailBox::Mail * pMail = pMailBox->GetMailData(mailSeq);
	if (NULL == pMail)
	{
		DEBUGLOG("CS_READ_MAIL_DELETE : pMail is NULL!!");
		return;
	}

	pMail->UpdateDeleteStatusDatabaseMail();
	pMailBox->DelMailData(mailSeq);

	::Network::Packet * pAck = ::Network::GETPACKETPOOL()->SEND_NEW();
	*pAck << static_cast<int16_t>(ACK_OK);
	pAck->MakePacket(CMD_SC_READ_MAIL_DELETE);
	pUser->Send(pAck);
}

} /*NCommand*/ } /*ProjectZ*/
